package com.ruoyi.system.service.impl;

import com.ruoyi.system.service.UserNucleicAcidCodeService;
import com.ruoyi.system.utils.AesTool;
import com.ruoyi.system.utils.QrCodeUtil;
import org.springframework.stereotype.Service;

@Service
public class UserNucleicAcidCodeServiceImpl implements UserNucleicAcidCodeService {


    @Override
    public String aesAndCode(Long uid, Long tid) throws Exception {
        // 钥匙
        String key = "aaaabbbbccccdddd";
        // 加密密文
        // uid转为String
        String strTUId = uid.toString();
        //AES加密uid
        String enResult = AesTool.enCode(strTUId, key);

        // tid转为String
        String strTId = tid.toString();
        //AES加密tid
        String deResult = AesTool.enCode(strTId, key);

        // http://localhost/hslog?user=CDJEIFJ34&task=FJE33JF ,
        // 拼接要生成二维码的字符串
        String codeUrl = "http://localhost/hslog?user="+enResult+"&task="+deResult;

        // 生成二维码
        String base64 = QrCodeUtil.getBase64(codeUrl, 100, 100);

        //AES解密
        //AesTool.deCode();

        return base64;
    }
}
